﻿using System.Collections.Generic;

namespace Sidvall.Data
{
    public abstract class FilterCriteriaBase<TField> : CriteriaBase
    {
        #region Public Members

        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2227:CollectionPropertiesShouldBeReadOnly")]
        public Filter<TField> Filter { get; set; }

        #region Clean

        public virtual void Clean(System.Collections.Generic.IEnumerable<string> validParameterKeys, IEnumerable<TField> validFilterFieldIds)
        {
            Clean(validParameterKeys);
            if (this.Filter != null)
                this.Filter.FilterItems.RemoveAllExcept(validFilterFieldIds);
        }
        public virtual void Clean(System.Collections.Generic.IEnumerable<string> validParameterKeys, IEnumerable<string> validFilterFieldNames)
        {
            Clean(validParameterKeys);
            if (this.Filter != null)
                this.Filter.FilterItems.RemoveAllExcept(validFilterFieldNames);
        }

        #endregion
        #region Clear

        public override void Clear()
        {
            base.Clear();
            this.Filter = null;
        }

        #endregion

        #endregion
    }
}
